package com.lanou3g.ptp.remind.entity;

import com.alibaba.dubbo.config.annotation.Reference;
import com.lanou3g.ptp.teacher.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class RecommendJob {

    @Autowired
    private StringRedisTemplate redisTemplate;

    @Reference
    private TeacherService teacherService;

    @Value("REMIND-RECOMMEND-")
    private String REDIS_RECOMMENDREMIND_KEY_PREFIX;
    public void RecommendRemind(Long taskId){

        String key = REDIS_RECOMMENDREMIND_KEY_PREFIX + taskId;

        List<Long> teacherIds = teacherService.findByTaskId(taskId);

        for (Long teacher : teacherIds) {

            redisTemplate.opsForValue().set(key,teacher.toString());

        }

    };


}
